package com.lagou.service;

import com.lagou.pojo.Article;
import com.lagou.pojo.ArticlePage;
import com.lagou.respository.ArticleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
 * @author sxnan
 * @className CommentService
 * @description TODO
 * @date 2020/7/9
 */
@Service
public class ArticleService {

    @Autowired
    private ArticleRepository repository;

    public Page<Article> findArticlePage(Integer pageNo, Integer pageSize){
        PageRequest pageRequest = PageRequest.of(pageNo,pageSize);
        Page<Article> all = repository.findAll(pageRequest);
//        ArticlePage articlePage = new ArticlePage();
//        articlePage.setTotalPage(all.getTotalPages());
//        articlePage.setArticles(all.getContent());
        return all;
    }

}
